home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d16
/
wspacer.arc
/
WSMAKE.WBT
< prev
next >
Wrap
Text File
|
1991-09-13
|
5KB
|
166 lines
; --- This is WSMAKE.WBT (a Batch Builder file that obtains WorkSpace
; information, storing it in a private INI file). WSRUN.WBT (a
; Batch Builder file that restores a named Workspace to the desktop)
; is paired with WSMAKE.WBT to complete WorkSpacer.
; --- WiGuys SoftWare
; 19 Rushbrook Drive,
; Kitchener, ON N2E 3C1
; (519) 745-9717
; Gregg J. Hommel, CIS # 72537,552
; --- WorkSpacer is freeware.
; --- Setup default variable strings and integers.
WinHide ( "WBT" )
spacelib = "c:\ndw\wspace.lib"
spacebak = "c:\ndw\wspace.bak"
maxhere = 4
newcount = 1
hortab = Num2Char (9)
crlf = StrCat ( Num2Char (13), Num2Char (10) )
tlfs = StrCat ( "%crlf%", "%crlf%" )
msg = ""
If FileExist (spacelib ) Then GoTo libwarn
msg = StrCat ( "There are no WorkSpaces created.", "%tlfs%" )
:libwarn
msg = StrCat ( "%msg%", "To create a WorkSpace, you must first : ", "%tlfs%" )
msg = StrCat ( "%msg%", "1) Load and position all the applications", "%crlf%" )
msg = StrCat ( "%msg%", "2) Run WorkSpacer to create the WorkSpace.", "%tlfs%" )
msg = StrCat ( "%msg%", " Is it OK to proceed with creating a WorkSpace?" )
ques = AskYesNo ( "WorkSpacer", "%msg%" )
if ques == @NO Then GoTo last
allwin = WinItemize ()
:doagain ; get the list of current windows
If newcount > 1 Then GoTo getdata
:wsname
msg = StrCat ( "What is the WorkSpace name?", "%crlf%" )
msg = StrCat ( "%msg%", "(Maximum - 30 characters)" )
grpname = AskLine ( "WorkSpacer Says", "%msg%", "" )
grpsize = StrLen ( grpname )
If !grpsize == 0 || grpsize < 31 Then GoTo checkgrp
Message ( "WorkSpacer Warning", "Invalid WorkSpace name")
GoTo wsname
:checkgrp ; Check for duplicate WorkSpace name.
If !FileExist ( spacelib ) Then GoTo getdata
fHandle = FileOpen ( spacelib, "READ" )
:retry
line = FileRead ( fHandle )
If StrICmp ( grpname, line ) == 0 Then GoTo askagain
If line == "*EOF*" Then GoTo getdata
GoTo retry
:askagain
reshere = AskYesNo ( "WorkSpacer", "Duplicate WorkSpace name! Try another?" )
If reshere == @YES Then GoTo doagain
GoTo last
:getdata ; get the information for the current application.
currwind = ItemSelect ( "Select an application", allwin, hortab )
If !StrICmp ( currwind, "" ) == 0 Then GoTo apppos
Message ( "WorkSpacer Warning", "Nothing was selected!" )
goto getdata
:apppos ; get the position of the app
currpos = WinPosition ( "%currwind%" )
:getname ; get the filename and path info
msg = StrCat ( "What is the application filename?", "%tlfs%" )
msg = StrCat ( "%msg%", "Include the extension ( EXE )", "%crlf%" )
msg = StrCat ( "%msg%", "and drive/path (if needed)." )
filename = AskLine ( "WorkSpacer", "%msg%", "" )
root = FileRoot ( filename ) ; validity checks
If StrLen ( "%root%" ) > 0 && StrLen ("%root%" ) < 9 Then GoTo extcheck
Message ( "WorkSpacer Warning", "Invalid file name" )
GoTo getname
:extcheck
ext = FileExtension ( filename )
If StrICmp ( ext, "exe" ) == 0 Then GoTo pathcheck
ext = "exe"
filename = StrCat ( filename, ".", ext )
:pathcheck
path = FilePath ( filename )
truepath = FileLocate ( filename )
If !StrICmp ( truepath, "" ) == 0 Then GoTo foundit
tryok = AskYesNo ( "WorkSpacer", "Incorrect Path/Filename. Reenter it?" )
If tryok == @NO Then GoTo last
GoTo getname
:foundit ;filename is fine, so update INI and LIB
If newcount == 1 Then GoTo writelib
tcount = 1
:loop ; check for duplicate filename in INI
tkey = StrCat ( "App", tcount )
tline = IniReadPvt ( grpname, tkey, filename, "wspace.ini" )
If StrICmp ( tline, filename ) == 0 Then GoTo dupefile
tcount = tcount + 1
If tcount == newcount Then GoTo writeini
GoTo loop
:dupefile
msg = StrCat ("That application is in the WorkSpace already!","%tlfs%" )
msg = StrCat ("%msg%", "Choose another application?" )
choose = AskYesNo ( "WorkSpacer", "%msg%" )
If choose == @NO Then GoTo last
GoTo getdata
:writelib ; take care of the LIB file
If FileExist ( spacelib ) Then GoTo oldspace
:newspace ; create a new LIB if needed
fHandle = FileOpen ( spacelib, "WRITE" )
FileWrite ( fHandle, "%grpname%" )
FileClose ( fHandle )
GoTo writeini
:oldspace ; update the old LIB file
FileRename ( spacelib, spacebak )
fHandle1 = FileOpen ( spacebak, "READ" )
fHandle2 = FileOpen ( spacelib, "WRITE" )
:top
line = FileRead ( fHandle1 )
If line == "*EOF*" Then GoTo stop
FileWrite ( fHandle2, "%line%" )
GoTo top
:stop
FileClose ( fHandle1 )
FileWrite ( fHandle2, "%grpname%" )
FileClose ( fHandle2 )
FileDelete ( spacebak )
:writeini ; create or update the INI file
key1 = StrCat ( "App", newcount )
key2 = StrCat ( "Pos", newcount )
key3 = StrCat ( "Win", newcount )
IniWritePvt ( grpname, key1, filename, "wspace.ini" )
IniWritePvt ( grpname, key2, currpos, "wspace.ini" )
IniWritePvt ( grpname, key3, currwind, "wspace.ini" )
If newcount == maxhere Then GoTo last
newcount = newcount + 1
more = AskYesNo ( "WorkSpacer Says", "Add another application?" )
If more == @NO Then GoTo last
GoTo doagain
:last ; YEAH !!! Finished, at last!
Return